﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Butcher.winform.EnterpriseForms.Departmentview;
using Traceability.Commont.DTOs.SectionDto;
using System.Text.Json;

namespace Butcher.winform.EnterpriseForms
{
    public partial class SlaughterCircleUpdate : Form
    {
        public SlaughterCircleUpdate()
        {
            InitializeComponent();
            string url = @"http://localhost:5229/api/Section/SectionHtml";
            HttpClient client = new HttpClient();
            QueryCondition condition = new QueryCondition();
            condition.pageindex = 1;
            condition.pagesize = 2;
            condition.sectionName = "";
            condition.sectionType = 0;
            condition.sectionStatus = 0;
            var content = new StringContent(JsonSerializer.Serialize<QueryCondition>(condition), Encoding.UTF8);
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type", "application/json");
            string result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
            JObject josnresult = JObject.Parse(result);
            var results = josnresult["neWsections"].Value<JArray>();
            List<NEWsection> ssss = results.ToObject<List<NEWsection>>();
            this.cb_Level.DataSource = ssss;
            this.cb_Level.DisplayMember = "DepartmentName";
            this.cb_Level.ValueMember = "Departmentid";
        }

        private void button_Click(object sender, EventArgs e)
        {
            
        }
    }
}
